/**
 * 作者: hxl
 * 日期: 2024-12-15 22:41:48
 * 备注: 用户七天乐活动表
 */
package com.motu.monstercity.server.game.userdata;

import com.motu.monstercity.server.game.commondata.act.Act;
import com.motu.monstercity.server.game.logic.ActManager;
import com.motu.vertx.module.utility.toolset.TimeUtils;
import com.motu.vertx.module.utility.toolset.Tool;

import java.sql.Time;

public class UserAct extends UserActModel {
    public static final long NEWCOMER_ACT_ID_START = 1000000L; // 新手主题活动的actId起始
    public static final long CUSTOM_ACT_ID_START = 5000000L; // 自定义主题活动的actId起始（回归活动）
    public static final long SELF_ACT_ID_START = 1000000000L; // 玩家自身活动的actId起始
    public UserAct() {
        super();
    }
    public UserAct(long userId) {
        putId(userId);
    }

    public UserAct(long userId,long actId) {
        super();
        putUserId(userId);
        putActId(actId);
    }

    public UserAct(long userId, long actId, int groupId, long startTime, long endTime) {
        putUserId(userId);
        putActId(actId);
        putGroupId(groupId);
        putStartTime(startTime);
        putEndTime(endTime);
    }

    /**
     * 活动是否开启
     */
    public boolean isOpen() {
        long curTime = TimeUtils.getCurTime();
        if (actId > NEWCOMER_ACT_ID_START) {
            return curTime > startTime && curTime < endTime;
        } else {
            Act act = ActManager.getAct(actId);
            if (act != null) {
                return curTime > act.getStartTime() && curTime < act.getEndTime();
            }
        }
        return false;
    }

//    public boolean isShow() {
//        long curTime = TimeUtils.getCurTime();
//        if (actId > NEWCOMER_ACT_ID_START) {
//            return curTime > startTime && curTime < endTime + TimeUtils.DAY;
//        } else {
//            Act act = ActManager.getAct(actId);
//            if (act != null) {
//                return curTime > act.getStartTime() && curTime < act.getEndTime();
//            }
//        }
//        return false;
//    }

    public int getDiffDay() {
        return TimeUtils.getDiffDay(startTime) + 1;
    }

}
